<?php
namespace app\api\controller;

use app\common\model as M;

/**
 * 签到任务
 */
class SignTask extends \app\api\ApiAuth
{
    public $model = '\app\common\model\SignTask';

    /**
     * 用户签到任务以及完成情况
     * @Author   FW
     * @DateTime 2024-03-18
     * @Email    123763712@qq.com
     * @return   [type]           [description]
     */
    public function tasks()
    {
        $tasks = $this->model::alias('m')->field("m.id,m.task_name,m.golds,ifnull(sr.complete_date,0) as is_complete")
        ->join('__SIGN_TASK_RECORDS__ sr',sprintf("m.id=sr.task_id AND sr.uid=%d",$this->uid) , 'LEFT')
        ->order(sprintf('m.sort %s',$this->model::DEFAULT_SORT_RULE))
        ->select();

        return $this->returnSuccess($tasks);
    }
}//Class End